<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>


<s:layout-render name="/backend/layout.jsp" title="moduleNames.hotels" selectedPage="hotels">
    <s:layout-component name="body">
        <s:useActionBean beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" var="actionBean"/>

        <s:form beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean">
            <jsp:setProperty name="actionBean" property="*"/>
            <div class="select-bar">
                <table>
                    <tr>
                        <th class="full"><label class="textarea"><f:message key="global.hotel.search.name_parameter" /></label>
                            <s:text size="20" name="hotelName"/>
                            <label><f:message key="global.hotel.search.city_parameter" /></label>
                            <s:text size="20" name="hotelCity"/>
                            <s:submit name="findHotelsByNameOrCity"><f:message key="global.search_hotels" /></s:submit></th>
                    </tr>
                </table>
            </div>
        </s:form>
        <div class="table">
            <table class="listing" cellpadding="0" cellspacing="0">
                <img src="${pageContext.request.contextPath}/backend/img/bg-th-left.gif" width="8" height="7" alt="" class="left" /> 
                <img src="${pageContext.request.contextPath}/backend/img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
                <tr>
                    <th class="first"><f:message key="entities.hotel.name" /></th>
                    <th><f:message key="entities.hotel.adress" /></th>                    
                    <th><f:message key="entities.hotel.city" /></th>
                    <th><f:message key="entities.hotel.rooms" /></th>
                    <th><f:message key="entities.reservation" /></th>
                    <th><f:message key="moduleNames.customers" /></th>
                    <th><f:message key="entities.hotel.description" /></th>
                    <shiro:hasRole name="admin"><th><f:message key="global.edit" /></th></shiro:hasRole>
                    <shiro:hasRole name="admin"><th class="last"><f:message key="global.delete" /></th></shiro:hasRole>
                </tr>
                <% int i = 0; %>
                <c:forEach var="hotel" items="${actionBean.getList()}" >
                    <tr <% if(i%2 == 0){ out.print(" class='bg' "); } i++; %> >
                        <td class="first_style1"><c:out value="${hotel.name}"/></td>
                        <td><c:out value="${hotel.adress}"/></td>   
                        <td><c:out value="${hotel.city}"/></td>
                        <td><s:link beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" event="getRooms"><s:param name="hotel.id" value="${hotel.id}" /><img src="${pageContext.request.contextPath}/backend/img/edit-icon.gif" /></s:link></td>                                               
                        <td><s:link beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" event="getReservations"><s:param name="hotel.id" value="${hotel.id}" /><img src="${pageContext.request.contextPath}/backend/img/edit-icon.gif" /></s:link></td>                       
                        <td><s:link beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" event="getBooking"><s:param name="hotel.id" value="${hotel.id}" /><img src="${pageContext.request.contextPath}/backend/img/edit-icon.gif" /></s:link></td>                        
                        <td class="last">${hotel.description}</td> 
                        <shiro:hasRole name="admin">
                        <td><s:link beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" event="edit"><s:param name="hotel.id" value="${hotel.id}" /><img src="${pageContext.request.contextPath}/backend/img/edit-icon.gif" /></s:link></td>
                        </shiro:hasRole>
                        <shiro:hasRole name="admin">
                        <td class="last"><s:link onclick="return confirm_delete()" beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" event="delete"><s:param name="hotel.id" value="${hotel.id}" /><img src="${pageContext.request.contextPath}/backend/img/hr.gif" /></s:link></td></tr>
                        </shiro:hasRole>
                </c:forEach>
            </table>                 
        </div>
        
        <shiro:hasRole name="admin" >
            <s:form beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean">               
                <c:import url="form.jsp">
                    <c:param name="header" value="global.add" />
                </c:import>
                <s:submit class="button" name="add"><f:message key="global.add" /></s:submit>
            <s:errors/> 
            </s:form>
        </shiro:hasRole>
                
    </s:layout-component>
</s:layout-render>
